﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using Wilke.Interactive.Drone.PlayGround.Controls;

namespace Wilke.Interactive.Drone.PlayGround.UserControls
{
    /// <summary>
    /// Interaction logic for PieMenu.xaml
    /// </summary>
    public partial class PieMenu : UserControl
    {
        public event EventHandler<SegmentClickedEventArgs> SegmentClicked;

        public PieMenu()
        {
            InitializeComponent();
        }

        private void PieMenu_SegmentClicked(object sender, SegmentClickedEventArgs e)
        {
            PieSegment pieSegment = pieMenuControl.Children[pieMenuControl.Children.Count - e.SegmentIndex - 1] as PieSegment;

            if (pieSegment != null)
            {
                pieSegment.Selected = !pieSegment.Selected;

                if (SegmentClicked != null)
                {
                    SegmentClicked(this, e);
                }
            }            
        }

        public void SelectSegment(int index, bool selected)
        {
            PieSegment pieSegment = pieMenuControl.Children[pieMenuControl.Children.Count - index - 1] as PieSegment;

            pieSegment.Selected = selected;
        }
    }
}
